package com.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import com.sky.service.ShoppingCartService;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface ShoppingCartMapper extends BaseMapper<ShoppingCart> {


    // 条件查询购物车(添加购物车中执行）
    ShoppingCart selectShoppingCart(@Param("dto") ShoppingCartDTO dto, @Param("userId") Long userId);

    // 修改菜品的数量和价格(添加购物车中执行）
    void updateShoppingCart(@Param("dto")ShoppingCartDTO shoppingCartDTO, @Param("price") BigDecimal price);

    // 查看购物车
    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> seeShoppingCart(Long userId);

    // 清空购物车
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void removeByUserId(Long userId);
}
